#!/usr/bin/python
#encoding=utf-8

'''
Created on May 8, 2014

@author: root
'''

from wm.db.TransactionManager import TransactionManager

def test():
    tran = TransactionManager()
    try:
        sql = "select pa.id,pa.uRLType,pa.elementURL,pa.local,wc.websitename,pa.websiteConfigInfo_id from pageanalyzer as pa,websiteconfiginfo as wc where pa.websiteConfigInfo_id = wc.id and wc.cluster=2"
        
        sql =  "select ms.stfcellphone,ms.stfemail,ms.stfname from maintenancestaffandweb as msw,websiteconfiginfo as wc,maintenancestaff as ms where msw.maintenanceStaff_id = ms.id  and msw.websiteConfigInfo_id = wc.id and wc.id ='402890da4245e815014245eee8780058'"
        
        
        palist = tran.select(sql) 
        print len(palist),palist
        tran.commitTransaction()
    except:
        tran.rollbackTransaction()
    finally:
        tran.close()
                        
if __name__=="__main__":
    test()
    '''
    t = TransactionManager()
    try:
        t.startTransaction()
        
        sql = "insert into test1(name) value('test1')"
        t.execute(sql)
        
        sql = "select * from test2"
        res = t.select(sql)
        if res:
            print res
            
        sql = "insert into test(name) value('40')"
        t.execute(sql)
        
 
        sql = "update test set name = 'luyoubing' where name = '40'"
        t.update(sql)
        
        t.commitTransaction()
    except:
        t.rollbackTransaction()
    finally:
        t.close()
    '''
